import { defHttp } from '/@/utils/http/axios';
import { ErrorMessageMode } from '/#/axios';
import {
  EhsBoardQueryConditionDto,
  EhsBoardOrgLatestStatusDTO,
  EhsBoardOrgQueryResultDto,
  EhsBoardDeptQueryResultDto,
  EhsBoardUnitQueryConditionDto,
  EhsBoardUnitQueryResultDto,
  EhsBoardTaskQueryConditionDto,
  EhsBoardTaskQueryResultItemDto,
  EhsBoardOrgUnitHazardsQueryConditionDto,
  EhsBoardOrgUnitHazardsQueryResultItemDto
} from './model/ehsBoardModel'

enum Api {
  QueryOrgBoard = '/ehs/board/org',  // 查询
  QueryDept = '/ehs/board/childs',
  GetOrgLatestStatus = '/ehs/board/latest',
  GetUnitLatestStatus = '/ehs/board/unitlatest', //获取指定单元最新安全状态
  QueryUnitBoard = '/ehs/board/unit',//统计指定单元的安全生产看板数据-stsUnit
  QueryOrgUnitTasksBoard = '/ehs/board/unittasks',//统计指定时间段内组织的各单元任务数据-stsOrgUnitTasks
  GetOrgUnitHazardsBoard = '/ehs/board/unithazards',//获取组织各单元的危险源看板数据-getOrgUnitHazards
}


/**
 * 查询组织安全状态-getOrgLatestStatus
 */
export function getOrgLatestStatus(id: string | number, mode: ErrorMessageMode = 'modal') {
  return defHttp.get<EhsBoardOrgLatestStatusDTO>(
    {
      url: Api.GetOrgLatestStatus,
      params: {
        id: id
      }
    }, {
    errorMessageMode: 'modal',
  }
  );
}

/**
 * 查询组织的看板数据-queryOrg
 */
export function queryOrgEhsBoard(param: EhsBoardQueryConditionDto, mode: ErrorMessageMode = 'modal') {
  return defHttp.post<EhsBoardOrgQueryResultDto>(
    {
      url: Api.QueryOrgBoard,
      params: param
    }, {
    errorMessageMode: 'modal',
  }
  );
}

/**
 * 查询指定部门的下级部门的看板数据-queryChildDepts
 */
export function queryChildDeptsEhsBoard(param: EhsBoardQueryConditionDto, mode: ErrorMessageMode = 'modal') {
  return defHttp.post<EhsBoardDeptQueryResultDto[]>(
    {
      url: Api.QueryDept,
      params: param
    }, {
    errorMessageMode: 'modal',
  }
  );
}

/**
 * 获取指定单元最新安全状态-getUnitLatestStatus
 */
export function getUnitLatestStatus(id: string, mode: ErrorMessageMode = 'modal') {
  return defHttp.get<EhsBoardOrgLatestStatusDTO>(
    {
      url: Api.GetUnitLatestStatus,
      params: {
        id: id
      }
    }, {
    errorMessageMode: 'modal',
  }
  );
}

/**
 * 统计指定单元的安全生产看板数据-stsUnit
 */
export function queryUnitEhsBoardStatistics(param: EhsBoardUnitQueryConditionDto, mode: ErrorMessageMode = 'modal') {
  return defHttp.post<EhsBoardUnitQueryResultDto>(
    {
      url: Api.QueryUnitBoard,
      params: param
    }, {
    errorMessageMode: 'modal',
  }
  );
}

/**
 * 统计指定时间段内组织的各单元任务数据-stsOrgUnitTasks
 */
export function stsEhsBoardOrgUnitsTaskCounts(param: EhsBoardTaskQueryConditionDto, mode: ErrorMessageMode = 'modal') {
  return defHttp.post<EhsBoardTaskQueryResultItemDto[]>(
    {
      url: Api.QueryOrgUnitTasksBoard,
      params: param
    }, {
    errorMessageMode: 'modal',
  }
  );
}

/**
 * 获取组织各单元的危险源看板数据-getOrgUnitHazards
 */
export function stsEhsBoardOrgUnitsHazardCounts(param: EhsBoardOrgUnitHazardsQueryConditionDto, mode: ErrorMessageMode = 'modal') {
  return defHttp.post<EhsBoardOrgUnitHazardsQueryResultItemDto[]>(
    {
      url: Api.GetOrgUnitHazardsBoard,
      params: param
    }, {
    errorMessageMode: 'modal',
  }
  );
}